from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import OrderViewSet, OrderActionViewSet, ReviewViewSet

# 创建路由器并注册视图集
router = DefaultRouter()
router.register(r'', OrderViewSet, basename='order')

# 订单操作视图集
action_router = DefaultRouter()
action_router.register(r'', OrderActionViewSet, basename='order-action')

urlpatterns = [
    path('', include(router.urls)),
    path('<int:pk>/', include([
        path('accept/', OrderActionViewSet.as_view({'post': 'accept'}), name='accept_order'),
        path('cancel/', OrderActionViewSet.as_view({'post': 'cancel'}), name='cancel_order'),
        path('complete/', OrderActionViewSet.as_view({'post': 'complete'}), name='complete_order'),
    ])),
    path('<int:order_id>/review/', ReviewViewSet.as_view({'post': 'create'}), name='add_review'),
]